#include "mq_send_receive.h"
#include <unistd.h>



int main(int argc, char const *argv[])
{   
    char *name="/my_queue";
    char buf[100];  
    mqd_t mqd=open_message_queue(name);
    while (1)
    {   
        memset(buf, 0, sizeof(buf));
        if(receive_buf(mqd, buf, 10) == -1){

            perror("Receive failed");
            
        }else
        {
            /* code */
            if (strcmp(buf, "exit") == 0)
            {
                close(mqd);
                mq_unlink(name);
                printf("我已释放所有资源\n");
                exit(EXIT_SUCCESS);
            }
            
            write(STDOUT_FILENO, buf, strlen(buf));
        }
        
    }
    
    
    

    return 0;
}
